package com.ewhale.feitengguest.ui.user.task.adapter

import androidx.recyclerview.widget.RecyclerView
import com.ewhale.feitengguest.R
import com.ewhale.feitengguest.databinding.ItemTipBinding
import com.ewhale.feitengguest.dto.NavigationDto
import com.simga.library.adapter.BindRecycAdapter
import com.simga.library.utils.glide.GlideUtil

/**
 * 作者：SimGa
 * 日期：2019/12/25
 * 时间：11:03
 * 包名：com.ewhale.feitengguest.ui.user.task.adapter
 */
class TipAdapter : BindRecycAdapter<ItemTipBinding, NavigationDto>() {
    override fun normalViewId(): Int {
        return R.layout.item_tip
    }
    override fun onBindViewHolder(mBinding: ItemTipBinding, itemData: NavigationDto, holder: RecyclerView.ViewHolder, position: Int) {
        if(itemData.id == -1){
            mBinding.ivCover.setImageResource(R.mipmap.home_icon_1)
            mBinding.tvTitle.text = "每日签到"
        }else{
            GlideUtil.loadCirclePicture(itemData.imgUrl,mBinding.ivCover,R.mipmap.home_icon_1)
            mBinding.tvTitle.text = itemData.title
        }
        holder.itemView.setOnClickListener {
            if(listenter!=null){
                listenter.onClick(position,itemData)
            }
        }
    }

    private lateinit var listenter :onItemClick

     fun setListener(listenter :onItemClick){
        this.listenter  = listenter
    }

     interface onItemClick{
        fun onClick(position:Int,itemData: NavigationDto)
    }

}